const Router = require('koa-router')
const { verifyAuth, verifyMoment } = require('../middleware/auth.middleware')
const { avatarHandler, wallHandler, picHandler, picResize } = require('../middleware/file.middleware')
const { saveAvatarInfo, saveWallInfo, savePicInfo } = require('../controller/file.controller')

const fileRouter = new Router({ prefix: "/upload" })

// 更新用户头像
fileRouter.post("/avatar", verifyAuth, avatarHandler, saveAvatarInfo)

// 更新用户壁纸
fileRouter.post("/wall", verifyAuth, wallHandler, saveWallInfo)

// 添加动态配图
fileRouter.post("/pic", verifyAuth, verifyMoment, picHandler, picResize, savePicInfo)

module.exports = fileRouter
